﻿using Architecture.API.Application.TraceabilityCommand.TraceabilitiesCommand;
using MediatR;
using Traceability.Domain.BreedDomain;
using Traceability.Domain.Service.TraceabilitiesServices;

namespace Architecture.API.Application.TraceabilityCommandHandler.TraceabilitiesCommandHandler
{
    public class ReverseTraceabilitiesCommandHandler : IRequestHandler<ReverseTraceabilitiesCommand, Traceabilities>
    {
        /// <summary>
        /// 免疫服务
        /// </summary>
        protected readonly ITraceabilitiesService traceabilitiesService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="traceabilitiesService">免疫服务</param>
        public ReverseTraceabilitiesCommandHandler(ITraceabilitiesService traceabilitiesService)
        {
            this.traceabilitiesService = traceabilitiesService;
        }

        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Traceabilities> Handle(ReverseTraceabilitiesCommand request, CancellationToken cancellationToken)
        {
            return await traceabilitiesService.GetTraceabilitiesModel(request.traceabilityId);
        }
    }
}
